<?php 
class ArrowLinkAction extends ArrowAbstractUIAction{
	
	public function configure(){
		parent::configure();
		$this->addProperties(array(
			"template" => null,
			"href" => null,
			"blank" => false,
		));
		$this->setDisplay(false);
	}
	
	public function generate(  IArrowModel $context = null ){
		
		
		
		if($this->getProperty("template")){
			$this->arguments["path"] = $this->getProperty("template");
			$href = ArrowTemplateLinker::getDefault()->generateTemplateLink( $this->arguments );
		}elseif($this->getProperty("href")){
			$href = $this->getProperty("href");
		}else{
			$href = "";
		}
		if($context){
			foreach($context as $key => $val){
				$href = str_replace("#".$key."#", $val, $href);
			}
		}
		
		if($this->getProperty("blank"))
			$target='target="_blank"';
		else
			$target='';
		
		return '<a '.parent::generateClass().' '.$target.' href="'.$href.'">'.$this->getName()."</a>";	
	}
}

?>